
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>模板方法模式 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../../../../../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../../../../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../../../../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../../../../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../../../../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../../../../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../../../../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../strategymode/" />
    
    
    <link rel="prev" href="../" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../../../../../">
            
                <a href="../../../../../../">
            
                    
                    说明
            
                </a>
            

            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../../../../../">
            
                <a href="../../../../../">
            
                    
                    设计模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1" >
            
                <span>
            
                    
                    创建型模式
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1.1" >
            
                <span>
            
                    
                    简单工厂模式
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.2" >
            
                <span>
            
                    
                    工厂方法模式
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.3" data-path="../../createdmodel/abstractfactorymode/">
            
                <a href="../../createdmodel/abstractfactorymode/">
            
                    
                    抽象工厂模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.4" data-path="../../createdmodel/bulidermode/">
            
                <a href="../../createdmodel/bulidermode/">
            
                    
                    建造者模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.5" data-path="../../createdmodel/prototypemode/">
            
                <a href="../../createdmodel/prototypemode/">
            
                    
                    原型模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.6" data-path="../../createdmodel/singletonmode/">
            
                <a href="../../createdmodel/singletonmode/">
            
                    
                    单例模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.1.2" data-path="../../structuredmodel/">
            
                <a href="../../structuredmodel/">
            
                    
                    结构型模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.2.1" data-path="../../structuredmodel/proxymode/">
            
                <a href="../../structuredmodel/proxymode/">
            
                    
                    代理模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.2" data-path="../../structuredmodel/adaptermode/">
            
                <a href="../../structuredmodel/adaptermode/">
            
                    
                    适配器模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.3" data-path="../../structuredmodel/bridgemode/">
            
                <a href="../../structuredmodel/bridgemode/">
            
                    
                    桥接模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.4" data-path="../../structuredmodel/decoratormode/">
            
                <a href="../../structuredmodel/decoratormode/">
            
                    
                    装饰模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.5" data-path="../../structuredmodel/facademode/">
            
                <a href="../../structuredmodel/facademode/">
            
                    
                    外观模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.6" data-path="../../structuredmodel/flyweightmode/">
            
                <a href="../../structuredmodel/flyweightmode/">
            
                    
                    享元模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.7" data-path="../../structuredmodel/compositemode/">
            
                <a href="../../structuredmodel/compositemode/">
            
                    
                    组合模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.1.3" data-path="../">
            
                <a href="../">
            
                    
                    行为型模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="2.1.3.1" data-path="./">
            
                <a href="./">
            
                    
                    模板方法模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.2" data-path="../strategymode/">
            
                <a href="../strategymode/">
            
                    
                    策略模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.3" data-path="../commandmode/">
            
                <a href="../commandmode/">
            
                    
                    命令模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.4" data-path="../chainofresponsibility/">
            
                <a href="../chainofresponsibility/">
            
                    
                    责任链模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.5" data-path="../statemode/">
            
                <a href="../statemode/">
            
                    
                    状态模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.6" data-path="../observermode/">
            
                <a href="../observermode/">
            
                    
                    观察者模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.7" data-path="../mediatormode/">
            
                <a href="../mediatormode/">
            
                    
                    中介者模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.8" data-path="../iteratormode/">
            
                <a href="../iteratormode/">
            
                    
                    迭代器模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.9" data-path="../visitormode/">
            
                <a href="../visitormode/">
            
                    
                    访问者模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.10" data-path="../mementomode/">
            
                <a href="../mementomode/">
            
                    
                    备忘录模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.11" data-path="../interpretermode/">
            
                <a href="../interpretermode/">
            
                    
                    解释器模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../../../../../../Nacos/">
            
                <a href="../../../../../../Nacos/">
            
                    
                    Nacos
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1.1" data-path="../../../../../../Nacos/Nacos-Introduction.html">
            
                <a href="../../../../../../Nacos/Nacos-Introduction.html">
            
                    
                    Nacos介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.2" data-path="../../../../../../Nacos/Nacos-Registration.html">
            
                <a href="../../../../../../Nacos/Nacos-Registration.html">
            
                    
                    Nacos注册中心
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.3" data-path="../../../../../../Nacos/Nacos-OpenFeign.html">
            
                <a href="../../../../../../Nacos/Nacos-OpenFeign.html">
            
                    
                    Nacos+OpenFeign
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../../../../../../Sortings/">
            
                <a href="../../../../../../Sortings/">
            
                    
                    排序算法
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1.1" data-path="../../../../../../Sortings/src/main/java/com/larscheng/www/InsertionSort/">
            
                <a href="../../../../../../Sortings/src/main/java/com/larscheng/www/InsertionSort/">
            
                    
                    插入排序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.2" data-path="../../../../../../Sortings/src/main/java/com/larscheng/www/shellSort/">
            
                <a href="../../../../../../Sortings/src/main/java/com/larscheng/www/shellSort/">
            
                    
                    希尔排序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.3" >
            
                <span>
            
                    
                    选择排序
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.4" >
            
                <span>
            
                    
                    堆排序
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.5" >
            
                <span>
            
                    
                    希尔排序
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../../../../.." >模板方法模式</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="&#x6A21;&#x677F;&#x65B9;&#x6CD5;&#x6A21;&#x5F0F;">&#x6A21;&#x677F;&#x65B9;&#x6CD5;&#x6A21;&#x5F0F;</h3>
<p>&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x64CD;&#x4F5C;&#x4E2D;&#x7684;&#x7B97;&#x6CD5;&#x9AA8;&#x67B6;&#x3001;&#x800C;&#x5C06;&#x7B97;&#x6CD5;&#x7684;&#x4E00;&#x4E9B;&#x6B65;&#x9AA4;&#x5EF6;&#x8FDF;&#x5230;&#x5B50;&#x7C7B;&#x4E2D;&#xFF0C;
&#x4F7F;&#x5F97;&#x5B50;&#x7C7B;&#x53EF;&#x4EE5;&#x4E0D;&#x6539;&#x53D8;&#x7B97;&#x6CD5;&#x7ED3;&#x6784;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x91CD;&#x5B9A;&#x4E49;&#x8BE5;&#x7B97;&#x6CD5;&#x7684;&#x67D0;&#x4E9B;&#x7279;&#x5B9A;&#x6B65;&#x9AA4;&#x3002;</p>
<p>&#x4ED6;&#x662F;&#x4E00;&#x79CD;&#x7C7B;&#x884C;&#x4E3A;&#x6A21;&#x5F0F;</p>
<p>eg&#xFF1A;</p>
<p>&#x4E00;&#x4E2A;&#x4EBA;&#x6BCF;&#x5929;&#x4F1A;&#x7ECF;&#x5386;&#x8D77;&#x5E8A;&#x3001;&#x5403;&#x996D;&#x3001;&#x5DE5;&#x4F5C;&#x3001;&#x7761;&#x89C9;&#x8FD9;&#x51E0;&#x4EF6;&#x4E8B;&#x60C5;&#xFF0C;&#x5176;&#x4E2D;&#x8D77;&#x5E8A;&#x3001;&#x5403;&#x996D;&#x3001;&#x7761;&#x89C9;&#x90FD;&#x662F;&#x76F8;&#x540C;&#x7684;&#xFF0C;&#x5DE5;&#x4F5C;&#x5185;&#x5BB9;&#x6BCF;&#x4E2A;&#x4EBA;&#x5374;&#x4E0D;&#x4E00;&#x6837;</p>
<p>&#x94F6;&#x884C;&#x529E;&#x4E1A;&#x52A1;&#xFF1A;&#x53D6;&#x53F7;&#x3001;&#x6392;&#x961F;&#x3001;&#x529E;&#x7406;&#x3001;&#x8BC4;&#x4EF7;&#xFF0C;&#x5176;&#x4E2D;&#x53D6;&#x53F7;&#x3001;&#x6392;&#x961F;&#x3001;&#x8BC4;&#x4EF7;&#x90FD;&#x76F8;&#x540C;&#xFF0C;&#x529E;&#x7406;&#x5185;&#x5BB9;&#x6BCF;&#x4E2A;&#x4EBA;&#x90FD;&#x4E0D;&#x540C;</p>
<p>&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x53EF;&#x4EE5;&#x5C06;&#x8FD9;&#x4E9B;&#x76F8;&#x540C;&#x7684;&#x6D41;&#x7A0B;&#x5B9A;&#x4E49;&#x4E3A;&#x6A21;&#x677F;&#xFF0C;&#x800C;&#x56E0;&#x4EBA;&#x800C;&#x5F02;&#x7684;&#x90E8;&#x5206;&#x7559;&#x7ED9;&#x5B9E;&#x73B0;&#x8005;&#x81EA;&#x7531;&#x51B3;&#x5B9A;</p>
<h3 id="&#x4F18;&#x7F3A;&#x70B9;">&#x4F18;&#x7F3A;&#x70B9;</h3>
<p>&#x4F18;&#x70B9;&#xFF1A;</p>
<p>&#x5C01;&#x88C5;&#x4E86;&#x4E0D;&#x53D8;&#x7684;&#x90E8;&#x5206;&#xFF08;&#x5C01;&#x88C5;&#x5728;&#x7236;&#x7C7B;&#xFF09;&#xFF0C;&#x6269;&#x5C55;&#x4E86;&#x53EF;&#x53D8;&#x90E8;&#x5206;&#xFF08;&#x5B50;&#x7C7B;&#x7EE7;&#x627F;&#x5B9E;&#x73B0;&#xFF09;</p>
<p>&#x5728;&#x7236;&#x7C7B;&#x4E2D;&#x63D0;&#x53D6;&#x516C;&#x5171;&#x90E8;&#x5206;&#x4EE3;&#x7801;&#xFF0C;&#x4EE3;&#x7801;&#x590D;&#x7528;&#x6027;&#x5F3A;</p>
<p>&#x6269;&#x5C55;&#x6027;&#x5F3A;</p>
<p>&#x7F3A;&#x70B9;&#xFF1A;</p>
<p>&#x6BCF;&#x4E2A;&#x4E0D;&#x540C;&#x7684;&#x5B9E;&#x73B0;&#x90FD;&#x9700;&#x8981;&#x4E00;&#x4E2A;&#x5B50;&#x7C7B;&#xFF0C;&#x7CFB;&#x7EDF;&#x7C7B;&#x6570;&#x91CF;&#x589E;&#x591A;</p>
<h3 id="&#x89D2;&#x8272;&#x53CA;&#x5B9E;&#x73B0;">&#x89D2;&#x8272;&#x53CA;&#x5B9E;&#x73B0;</h3>
<ul>
<li>&#x62BD;&#x8C61;&#x7C7B;&#xFF1A;&#x8D1F;&#x8D23;&#x7ED9;&#x51FA;&#x4E00;&#x4E2A;&#x7B97;&#x6CD5;&#x7684;&#x9AA8;&#x67B6;&#xFF0C;&#x5176;&#x4E2D;&#x5305;&#x542B;&#x6A21;&#x677F;&#x65B9;&#x6CD5;&#x548C;&#x57FA;&#x672C;&#x65B9;&#x6CD5;<ul>
<li>&#x6A21;&#x677F;&#x65B9;&#x6CD5;&#xFF1A;&#x5B9A;&#x4E49;&#x9AA8;&#x67B6;&#xFF0C;&#x6309;&#x7167;&#x67D0;&#x79CD;&#x987A;&#x5E8F;&#x8C03;&#x7528;&#x5176;&#x4E2D;&#x7684;&#x57FA;&#x672C;&#x65B9;&#x6CD5;</li>
<li>&#x57FA;&#x672C;&#x65B9;&#x6CD5;&#xFF1A;&#x6574;&#x4E2A;&#x7B97;&#x6CD5;&#x9AA8;&#x67B6;&#x4E2D;&#x7684;&#x4E00;&#x4E2A;&#x6B65;&#x9AA4;&#xFF0C;&#x5176;&#x4E2D;&#x5206;&#x4E3A;&#xFF1A;<ul>
<li>&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#xFF1A;&#x5728;&#x62BD;&#x8C61;&#x7C7B;&#x4E2D;&#x58F0;&#x660E;&#xFF0C;&#x5177;&#x4F53;&#x6709;&#x5B50;&#x7C7B;&#x5B9E;&#x73B0;</li>
<li>&#x5177;&#x4F53;&#x65B9;&#x6CD5;&#xFF1A;&#x5728;&#x62BD;&#x8C61;&#x7C7B;&#x4E2D;&#x5DF2;&#x7ECF;&#x5B9E;&#x73B0;&#xFF0C;&#x5728;&#x5B50;&#x7C7B;&#x4E2D;&#x53EF;&#x7EE7;&#x627F;&#x6216;&#x8005;&#x91CD;&#x5199;</li>
<li>&#x94A9;&#x5B50;&#x65B9;&#x6CD5;&#xFF1A;&#x5728;&#x62BD;&#x8C61;&#x7C7B;&#x4E2D;&#x5DF2;&#x7ECF;&#x5B9E;&#x73B0;&#xFF0C;&#x5305;&#x62EC;&#x7528;&#x4E8E;&#x5224;&#x65AD;&#x7684;&#x903B;&#x8F91;&#x65B9;&#x6CD5;&#x548C;&#x9700;&#x8981;&#x5B50;&#x7C7B;&#x91CD;&#x5199;&#x7684;&#x7A7A;&#x65B9;&#x6CD5;&#x4E24;&#x79CD;</li>
</ul>
</li>
</ul>
</li>
<li>&#x5177;&#x4F53;&#x5B50;&#x7C7B;&#xFF1A;&#x5B9E;&#x73B0;&#x62BD;&#x8C61;&#x7C7B;&#x4E2D;&#x5B9A;&#x4E49;&#x7684;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#x548C;&#x94A9;&#x5B50;&#x65B9;&#x6CD5;</li>
</ul>
<p><img src="http://c.biancheng.net/uploads/allimg/181116/3-1Q116095405308.gif" alt=""></p>
<pre><code class="lang-java"><span class="hljs-comment">/**
 * &#x63CF;&#x8FF0;:&#x6A21;&#x677F;&#x65B9;&#x6CD5;&#x6A21;&#x5F0F;
 *
 * <span class="hljs-doctag">@author</span> lars
 * <span class="hljs-doctag">@date</span> 2019/7/10 10:16
 */</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TemplateModeTest</span> </span>{

    <span class="hljs-comment">/***
     * &#x62BD;&#x8C61;&#x7C7B;
     */</span>
    <span class="hljs-keyword">abstract</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">AbstractClass</span></span>{
        <span class="hljs-comment">/***
         * &#x6A21;&#x677F;&#x65B9;&#x6CD5;
         */</span>
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">templateMethod</span><span class="hljs-params">()</span></span>{
            specificMethod();
            abstractMethodA();
            abstractMethodB();
        }

        <span class="hljs-comment">/**
         * &#x5177;&#x4F53;&#x65B9;&#x6CD5;
         */</span>
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">specificMethod</span><span class="hljs-params">()</span> </span>{
            System.out.println(<span class="hljs-string">&quot;&#x62BD;&#x8C61;&#x7C7B;&#x4E2D;&#x7684;&#x5177;&#x4F53;&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;...&quot;</span>);
        }

        <span class="hljs-comment">/**
         * &#x62BD;&#x8C61;&#x65B9;&#x6CD5;1
         */</span>
        <span class="hljs-function"><span class="hljs-keyword">protected</span> <span class="hljs-keyword">abstract</span> <span class="hljs-keyword">void</span> <span class="hljs-title">abstractMethodB</span><span class="hljs-params">()</span></span>;

        <span class="hljs-comment">/**
         * &#x62BD;&#x8C61;&#x65B9;&#x6CD5;2
         */</span>
        <span class="hljs-function"><span class="hljs-keyword">protected</span> <span class="hljs-keyword">abstract</span> <span class="hljs-keyword">void</span> <span class="hljs-title">abstractMethodA</span><span class="hljs-params">()</span></span>;

    }


    <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ConcreteClass</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">AbstractClass</span></span>{
        <span class="hljs-meta">@Override</span>
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">abstractMethodB</span><span class="hljs-params">()</span> </span>{
            System.out.println(<span class="hljs-string">&quot;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;1&#x7684;&#x5B9E;&#x73B0;&#x88AB;&#x8C03;&#x7528;..&quot;</span>);
        }

        <span class="hljs-meta">@Override</span>
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">abstractMethodA</span><span class="hljs-params">()</span> </span>{
            System.out.println(<span class="hljs-string">&quot;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;2&#x7684;&#x5B9E;&#x73B0;&#x88AB;&#x8C03;&#x7528;..&quot;</span>);
        }
    }


    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> </span>{
        AbstractClass abstractClass = <span class="hljs-keyword">new</span> ConcreteClass();
        abstractClass.templateMethod();
    }
}
</code></pre>
<h3 id="&#x6A21;&#x62DF;&#x573A;&#x666F;">&#x6A21;&#x62DF;&#x573A;&#x666F;</h3>
<p> &#x6BD4;&#x5982;&#x6625;&#x8FD0;&#x56DE;&#x5BB6;&#x4F1A;&#x7ECF;&#x5386;&#xFF1A;&#x4E70;&#x7968;&#x3001;&#x5230;&#x8FBE;&#x8F66;&#x7AD9;&#x3001;&#x68C0;&#x7968;&#x3001;&#x4E0A;&#x8F66;&#x3001;&#x5230;&#x8FBE;&#x76EE;&#x7684;&#x5730;</p>
<p> &#x5176;&#x4E2D;&#x6574;&#x4F53;&#x7684;&#x6D41;&#x7A0B;&#x76F8;&#x540C;&#xFF0C;&#x4F46;&#x662F;&#x6BCF;&#x4E2A;&#x4EBA;&#x6625;&#x8FD0;&#x56DE;&#x5BB6;&#x7684;&#x4EA4;&#x901A;&#x5DE5;&#x5177;&#x662F;&#x4E0D;&#x540C;&#x7684;</p>
<p> &#x5176;&#x4E2D; 
 &#x62BD;&#x8C61;&#x7C7B;&#xFF1A;&#x6625;&#x8FD0;&#x56DE;&#x5BB6;&#xFF0C;&#x6A21;&#x677F;&#x65B9;&#x6CD5;&#xFF08;&#x4E70;&#x7968;&#x3001;&#x5230;&#x8FBE;&#x8F66;&#x7AD9;&#x3001;&#x68C0;&#x7968;&#x3001;&#x4E0A;&#x8F66;&#x3001;&#x5230;&#x8FBE;&#x76EE;&#x7684;&#x5730;&#xFF09;&#xFF0C;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#xFF08;&#x4E70;&#x7968;&#x3001;&#x5230;&#x8FBE;&#x8F66;&#x7AD9;&#x3001;&#x4E0A;&#x8F66;&#xFF09;&#x5177;&#x4F53;&#x65B9;&#x6CD5;&#xFF08;&#x68C0;&#x7968;&#x3001;&#x5230;&#x8FBE;&#x76EE;&#x7684;&#x5730;&#xFF09;<br> &#x5750;&#x706B;&#x8F66;&#x56DE;&#x5BB6;&#xFF1A;&#x5177;&#x4F53;&#x7C7B;<br> &#x5750;&#x9AD8;&#x94C1;&#x56DE;&#x5BB6;&#xFF1A;&#x5177;&#x4F53;&#x7C7B; </p>
<p><img src="https://raw.githubusercontent.com/larscheng/myImg/master/blogImg/DesignPatterns/20190710110446.png" alt=""></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../" class="navigation navigation-prev " aria-label="Previous page: 行为型模式">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../strategymode/" class="navigation navigation-next " aria-label="Next page: 策略模式">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"模板方法模式","level":"2.1.3.1","depth":3,"next":{"title":"策略模式","level":"2.1.3.2","depth":3,"path":"Design-Patterns/src/main/java/behavioralmodel/strategymode/README.md","ref":"Design-Patterns/src/main/java/behavioralmodel/strategymode/README.md","articles":[]},"previous":{"title":"行为型模式","level":"2.1.3","depth":2,"path":"Design-Patterns/src/main/java/behavioralmodel/README.md","ref":"Design-Patterns/src/main/java/behavioralmodel/README.md","articles":[{"title":"模板方法模式","level":"2.1.3.1","depth":3,"path":"Design-Patterns/src/main/java/behavioralmodel/templatemethodmode/README.md","ref":"Design-Patterns/src/main/java/behavioralmodel/templatemethodmode/README.md","articles":[]},{"title":"策略模式","level":"2.1.3.2","depth":3,"path":"Design-Patterns/src/main/java/behavioralmodel/strategymode/README.md","ref":"Design-Patterns/src/main/java/behavioralmodel/strategymode/README.md","articles":[]},{"title":"命令模式","level":"2.1.3.3","depth":3,"path":"Design-Patterns/src/main/java/behavioralmodel/commandmode/README.md","ref":"Design-Patterns/src/main/java/behavioralmodel/commandmode/README.md","articles":[]},{"title":"责任链模式","level":"2.1.3.4","depth":3,"path":"Design-Patterns/src/main/java/behavioralmodel/chainofresponsibility/README.md","ref":"Design-Patterns/src/main/java/behavioralmodel/chainofresponsibility/README.md","articles":[]},{"title":"状态模式","level":"2.1.3.5","depth":3,"path":"Design-Patterns/src/main/java/behavioralmodel/statemode/README.md","ref":"Design-Patterns/src/main/java/behavioralmodel/statemode/README.md","articles":[]},{"title":"观察者模式","level":"2.1.3.6","depth":3,"path":"Design-Patterns/src/main/java/behavioralmodel/observermode/README.md","ref":"Design-Patterns/src/main/java/behavioralmodel/observermode/README.md","articles":[]},{"title":"中介者模式","level":"2.1.3.7","depth":3,"path":"Design-Patterns/src/main/java/behavioralmodel/mediatormode/README.md","ref":"Design-Patterns/src/main/java/behavioralmodel/mediatormode/README.md","articles":[]},{"title":"迭代器模式","level":"2.1.3.8","depth":3,"path":"Design-Patterns/src/main/java/behavioralmodel/iteratormode/README.md","ref":"Design-Patterns/src/main/java/behavioralmodel/iteratormode/README.md","articles":[]},{"title":"访问者模式","level":"2.1.3.9","depth":3,"path":"Design-Patterns/src/main/java/behavioralmodel/visitormode/README.md","ref":"Design-Patterns/src/main/java/behavioralmodel/visitormode/README.md","articles":[]},{"title":"备忘录模式","level":"2.1.3.10","depth":3,"path":"Design-Patterns/src/main/java/behavioralmodel/mementomode/README.md","ref":"Design-Patterns/src/main/java/behavioralmodel/mementomode/README.md","articles":[]},{"title":"解释器模式","level":"2.1.3.11","depth":3,"path":"Design-Patterns/src/main/java/behavioralmodel/interpretermode/README.md","ref":"Design-Patterns/src/main/java/behavioralmodel/interpretermode/README.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["expandable-chapters","livereload"],"pluginsConfig":{"expandable-chapters":{},"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"Design-Patterns/src/main/java/behavioralmodel/templatemethodmode/README.md","mtime":"2019-07-10T03:05:16.014Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-09-09T07:20:35.937Z"},"basePath":"../../../../../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../../../../../gitbook/gitbook.js"></script>
    <script src="../../../../../../gitbook/theme.js"></script>
    
        
        <script src="../../../../../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../../../../../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../../../../../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../../../../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../../../../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../../../../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../../../../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../../../../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

